#include <iostream>
#include <cstdio>
#include <vector>
#include <deque>
#include <algorithm>

using std::vector;
using std::cin;
using std::cout;
using std::min;
using std::pair;
using std::reverse;

void input(vector < vector <int> > &lst) {
    int n, a, b;
    cin >> n;
    lst.resize(2 * n);
    for (int i = 0; i < 2 * n; i += 2) {
        lst[i].push_back(i + 1);
    }
    cin >> a >> b;
    for (int i = 0; i < a; i++) {
        int x, y;
        cin >> x >> y;
        lst[2 * x - 1].push_back(2 * y - 2);
    }
    for (int i = 0; i < b; i++) {
        int x, y;
        cin >> x >> y;
        lst[2 * x - 2].push_back(2 * y - 1);
        lst[2 * y - 2].push_back(2 * x - 1);
    }
}

bool dfs(int s, const vector < vector <int> > &lst, vector <char> &used,
         vector <int> &topsort) {
    bool flag = true;
    used[s] = 1;
    for (int i = 0; i < lst[s].size(); i++) {
        int to = lst[s][i];
        if (used[to] == 1) {
            return false;
        }
        if (!used[to]) {
            flag &= dfs(to, lst, used, topsort);
        }
    }
    used[s] = 2;
    topsort.push_back(s);
    return flag;
}

bool solution(const vector < vector <int> > &lst, vector <pair <int, int> > &segments) {
    bool flag = true;
    vector <int> topsort;
    vector <char> used(lst.size(), 0);
    for (int i = 0; i < lst.size(); i++) {
        if (!used[i]) {
            flag &= dfs(i, lst, used, topsort);
        }
    }
    reverse(topsort.begin(), topsort.end());
    if (flag) {
        segments.resize(lst.size() / 2);
        for (int i = 0; i < topsort.size(); i++) {
            if(topsort[i] & 1) {
                segments[topsort[i] / 2].second = i;
            } else {
                segments[topsort[i] / 2].first = i;
            }
        }
    }
    return flag;
}

void output(bool answer, const vector <pair <int, int> > &segments) {
    if(!answer) {
        cout << "Impossible";
        return;
    }
    for (int i = 0; i < segments.size(); i++) {
        cout << segments[i].first << ' ' << segments[i].second << '\n';
    }
}

int main() {
    vector <pair <int, int> > segments;
    vector < vector <int> > lst;
    bool answer;
    input(lst);
    answer = solution(lst, segments);
    output(answer, segments);
    return 0;
}
